<?php

namespace common\extensions;

use yii\base\BaseObject;

/**
 * Desc 所有服务的基类(必须继承)
 * @author HUI
 */
class BaseService extends BaseObject {

    /**
     * @desc   json出错返回

     * @param  string $msg
     * @return json
     */
    protected static function jsonError($message = '请求异常', $data = []) {
        return ['code' => 201, 'message' => $message, 'data' => $data];
    }

    /**
     * @desc   json成功返回
     * @param  array $data
     * @return json
     */
    protected static function jsonSuccess($data = [], $message = '请求成功') {
        return ['code' => 200, 'message' => $message, 'data' => $data];
    }

}
